package com.hc.comm.utils;

import java.util.ArrayList;
import java.util.List;


/**
 * 常量集合
 * 
 * @author 
 * 
 */
public class Constant {
	/**
	 * 数据库类型
	 * 
	 */
	public static class DbTypes {

		/**
		 * 目前支持的数据库类型
		 * 
		 */
		public enum DbTypeEnum {
			ORACLE("oracle"), SQLSERVER("sqlserver"), MYSQL("mysql");
			private String value;

			private DbTypeEnum(String value) {
				this.value = value;
			}

			public String getValue() {
				return value;
			}

			public void setValue(String value) {
				this.value = value;
			}
		}

		// 支持的数据库类型列表,目前只支持oracle，sqlserver，mysql
		public static List<String> dbTypeList = new ArrayList<String>();
		static {
			dbTypeList.add(DbTypeEnum.ORACLE.getValue());
			dbTypeList.add(DbTypeEnum.SQLSERVER.getValue());
			dbTypeList.add(DbTypeEnum.MYSQL.getValue());
		}

		/**
		 * 数据库是否是oracle
		 * 
		 * @param dbType
		 * @return
		 */
		public static boolean isOracle(String dbType) {
			if (StringUtil.isNotEmpty(dbType)
					&& DbTypeEnum.ORACLE.getValue().equals(dbType)) {
				return true;
			}
			return false;
		}

		/**
		 * 数据库是否是sqlserver
		 * 
		 * @param dbType
		 * @return
		 */
		public static boolean isSqlserver(String dbType) {
			if (StringUtil.isNotEmpty(dbType)
					&& DbTypeEnum.SQLSERVER.getValue().equals(dbType)) {
				return true;
			}
			return false;
		}

		/**
		 * 数据库是否是mysql
		 * 
		 * @param dbType
		 * @return
		 */
		public static boolean isMysql(String dbType) {
			if (StringUtil.isNotEmpty(dbType)
					&& DbTypeEnum.MYSQL.getValue().equals(dbType)) {
				return true;
			}
			return false;
		}
	}

	/**
	 * 操作结果主要的几个类型(1000：成功，1001：异常，1002：操作错误，1003：没有登录，
	 * 1004：无权访问，1005：提示信息，2000:其他结果[ 需要加二级状态码判断])
	 * 
	 * @author Ready 2012-10-17
	 */
	public enum ResultEnum {
		// 成功,失败,没有登录,无权限,其他
		SUCCESS("1000", "SUCCESS"), ERROR("1001", "ERROR"), OPERATEEXCEPTION(
				"1002", "OPERATEEXCEPTION"), NOLOGIN("1003", "NOLOGIN"), NOPERMISSION(
				"1004", "NOPERMISSION"), INFO("1005", "INFO"), OTHER("2000",
				"OTHER"), NOTFINDPAGE("404", "没有找到该页面");
		private String result;

		private String desc;


		private ResultEnum(String result, String desc) {
			this.result = result;
			this.desc = desc;
		}

		public String getResult() {
			return result;
		}

		public void setResult(String result) {
			this.result = result;
		}

		public String getDesc() {
			return desc;
		}

		public void setDesc(String desc) {
			this.desc = desc;
		}

		@Override
		public String toString() {
			return this.result;
		}
	}

	/**
	 * 内容类型
	 * 
	 */
	public enum ContentTypeEnum {
		TEXT_HTML("text/html; charset=UTF-8"), TEXT_PLAIN(
				"text/plain; charset=UTF-8");
		String value;

		private ContentTypeEnum(String value) {
			this.value = value;
		}

		public String getValue() {
			return value;
		}
	}

	/**
	 * servle中的范围枚举
	 * 
	 * @author Ready 2012-10-17
	 */
	public enum HttpScopeEnum {

		REQUEST("request"), SESSION("session"), APPLICATION("application");
		private String scope;

		private HttpScopeEnum(String scope) {
			this.scope = scope;
		}

		public String getScope() {
			return scope;
		}

		public void setScope(String scope) {
			this.scope = scope;
		}
	}

	/**
	 * 系统一些资源文件名称
	 * 
	 * @author ready
	 * 
	 */
	public enum PropertiesFileEnum {

		WEB("web.properties"), CONST("const.properties");

		private String filename;

		public String getFilename() {
			return filename;
		}

		public void setFilename(String filename) {
			this.filename = filename;
		}

		PropertiesFileEnum(String filename) {
			this.filename = filename;
		}
	}





}
